#include "utils/utils.h"

/**
 * 获取并转化svg图标
 */
QIcon svgToIcon(QString svgPath) {
    QSvgRenderer minRenderer(svgPath);
    QPixmap pixmap(32, 32);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    minRenderer.render(&painter);
    QIcon icon(pixmap);
    return icon;
}

QString getDateTimeToFormat() {
    QDateTime currentTime = QDateTime::currentDateTime();
    QDate date = currentTime.date();
    int year = date.year();
    int month = date.month();
    int day = date.day();
    QTime time = currentTime.time();
    int hour = time.hour();
    int minute = time.minute();
    int second = time.second();
    QString timeStr = QString("%1-%2-%3 %4:%5:%6")
                          .arg(year, 2, 10, QChar('0'))
                          .arg(month, 2, 10, QChar('0'))
                          .arg(day, 2, 10, QChar('0'))
                          .arg(hour, 2, 10, QChar('0'))
                          .arg(minute, 2, 10, QChar('0'))
                          .arg(second, 2, 10, QChar('0'));
    return timeStr;
}